import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import {SharedModule} from '../shared.module';
import {MODAL_WIDTH} from '../../const'
import {Department} from '../../types/resp/Department';

@Component({
  selector: 'department-view',
  imports: [
    SharedModule
  ],
  templateUrl: './department-view.component.html',
  standalone: true
})
export class DepartmentViewComponent implements OnInit {
  departmentForm!: FormGroup;
  isVisible: boolean = false
  title: string = '部门信息详情'
  modalWidth: string = MODAL_WIDTH

  constructor(
    private fb: FormBuilder
  ) {}

  ngOnInit(): void {
    this.departmentForm = this.fb.group({
      enterpriseName: [''],
      departmentName: [''],
      parentDepartmentName: [''],
      departmentDescription: [''],
      createTime: [''],
      modifyTime: [''],
    })
  }

  onBack() {
    this.isVisible = false
  }

  display(department: Department) {
    this.isVisible = true
    this.departmentForm.patchValue(department);
    this.departmentForm.disable();
  }
}
